﻿using BusinessLogicLayer;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace PresentationLayer
{
    public partial class frmLoadNV : Form
    {
        public HienThiDSTKNV HienThiDS;

        public frmLoadNV()
        {
            InitializeComponent();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void btnLoad_Click(object sender, EventArgs e)
        {
            ActionResultAsList<NhanVien> ar = new NhanVienManager().LayDS();
            if (ar.Success)
            {
                if (radCoHuu.Checked)
                    ar.ObjectList.RemoveAll(n => n.TrangThai == TrangThaiNV.OnSite || n.TrangThai == TrangThaiNV.NghiViec);
                else
                    if (radNghiViec.Checked)
                        ar.ObjectList.RemoveAll(n => n.TrangThai != TrangThaiNV.NghiViec);
                    else
                        if (radOnSite.Checked)
                            ar.ObjectList.RemoveAll(n => n.TrangThai != TrangThaiNV.OnSite);
                if (ar.ObjectList.Count == 0)
                    MessageBox.Show("Không tìm thấy danh sách thỏa yêu cầu!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                else
                    HienThiDS(ar.ObjectList);
            }
            else
                MessageBox.Show(ar.Exceptions[ar.Exceptions.Count - 1].Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            Close();
        }
    }
}
